﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;

namespace SoccerSimulator5000
{
    public partial class SaveAsForm : Form
    {
        public SaveAsForm()
        {
            InitializeComponent();
        }

        static public void Serialize(string filename, DataClass game)
        {


            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(DataClass));
                using (TextWriter writer = new StreamWriter(filename))
                {
                    serializer.Serialize(writer, game);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            DataClass theGame = new DataClass();
            string filename = filenameTextbox.Text + ".xml";
            Serialize(filename, theGame);
        }
    }
}
